package com.wn.product.impl;

import com.wn.client.UserDubboClient;
import com.wn.domain.User;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yellow Docter
 * @date 2022 -10-31
 * @desc
 *  提供方法 把服务暴露出去
 *
 */
@DubboService
public class UserDubboClientImpl implements UserDubboClient {

    @Override
    public String hello(String id) {
        System.out.println("id = " + id);
        return "product service  ===>" + id;
    }


    @Override
    public User findUserById(Integer id) throws Exception {

        if (id > 10){

            throw new Exception("抛出异常");
        }

        User user = new User();
        user.setName("hello");
        user.setAge(12);
        return user;
    }

    @Override
    public String removeUserById(Integer id) {
        return "删除成功...";
    }

    @Override
    public List<User> findAll() {

        List<User> users =new ArrayList<>();

        User user = new User();
        user.setName("hello");
        user.setAge(12);

        User user2 = new User();
        user2.setName("abc");
        user2.setAge(22);

        users.add(user);
        users.add(user2);

        return users;
    }

}
